#include <bits/stdc++.h>
using namespace std;

struct car
{
    int d;
    int a;
    int v;
} l[100005]; //Every Car's infomation
int n, m, T, L, V;
int p[100005]; //Every P's pos

bool c1[100005];
bool c2[100005];
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    cin >> T;
    for (int o = 1; o <= T; o++)
    {
        memset(l, 0, sizeof(l));
        memset(p, 0, sizeof(p));
        memset(c1, 0, sizeof(c1));
        cin >> n >> m >> L >> V;
        int ans = 0, ans1 = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> l[i].d >> l[i].v >> l[i].a;
        }
        for (int i = 1; i <= m; i++)
        {
            cin >> p[i];
        } //cin

        for (int i = 1; i <= n; i++)
        {                           //Every Car
            //printf("Car #%d: ", i); //------------------------------------------------------
            memset(c2, 0, sizeof(c2));
            int p1 = 0;
            bool flag = false;
            int d = l[i].d, a = l[i].a, v = l[i].v;
            //printf("d:%d a:%d v:%d ", d, a, v); //------------------------------------------------------
            int Xmax = L + 10;
            if (l[i].a < 0)
                Xmax = int((v * v * 1.0) / (-2.0 * a));
            //printf("Xmax:%d\n", Xmax); //------------------------------------------------------
            for (int j = 1; j <= m; j++)
            {                                      //Every P
                //printf("\tP #%d: l=%d ", j, p[j]); //------------------------------------------------------
                if (p[j] >= d)
                {
                    int dx = p[j] - d;
                    if ((dx <= Xmax) && ((v * v + 2 * a * dx) > (V * V)))
                    {
                        c2[++p1] = j;
                        //printf("Detect!! "); //------------------------------------------------------
                        flag = true;
                    }
                    //printf("dx:%d v^2+2ax:%d V^2:%d\n", dx, (v * v + 2 * a * dx), (V * V)); //------------------------------------------------------
                }
            }
            c2[0] = p1;
            if (flag){
                ans++;
                //printf("\tans++ now:%d\n", ans);
            }
            else{}
            int dans=1;
            for (int w = 1; w <= p1; w++)
            {
                if(c1[c2[w]]){
                    dans = 0;
                    break;
                }
            }
            ans1 += dans;
            if(dans!=0){
                for (int w = 1; w <= p1; w++)
                {
                    c1[c2[w]] = 1;
                }
            }
        }

        printf("%d %d\n", ans, ans1);
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}